package com.example.newsmanager.util;

import java.io.File;
import java.net.URI;
import java.net.URL;

public class CoverUtil {
    public String FileToUrlExample(String filePath) {
            // 本地文件路径
            try {
                // 创建File对象
                File file = new File(filePath);

                // 获取文件的URI
                URI uri = file.toURI();
                System.out.println(uri);

                // 将URI转换为URL
                URL url = uri.toURL();
                // 打印URL
                System.out.println("URL: " + url);
                return String.valueOf(url);
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }

        }
}
